<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../code/jquery/jquery-1.8.0.js"></script>
</head>
<body>
姓名：<input type="text" name="name">
    <input type="submit" value="修改" onclick="f1()">
    <script>
        
        
        $(document).ready(function(){
            $.ajax({
                type: "get",//请求类型
                datatype: "json",//数据类型
                url: "./demo.json",//向哪里请求
                success: function(data){//请求成功后执行该函数
                    console.log("demo.json: "+data.name)//tom
                  document.body.innerHTML=data.name
                }
            })
        })
    </script>
    <script>
        
        var input1 = document.querySelector("input[name='name']")
        
            $(document).ready(function(){
            $.ajax({
                type: "get",//请求类型
                datatype: "json",//数据类型
                url: "./demo.json",//向哪里请求
                success: function(data){//请求成功后执行该函数
                    //console.log(data.name)//tom
                  var org_name = data.name
                }
            })
        })
        input1.value=org_name
        
        
        function f1(){
            $(document).ready(function(){
            $.ajax({
                type: "post",//请求类型
                datatype: "json",//数据类型
                url: "./demo.json",//向哪里请求
                success: function(data){//请求成功后执行该函数
                    //console.log(data.name)//tom
                  
                }
            })
        })
            data.name=input1.value
        }
        
            
            
            
            
    </script>
</body>
</html>
